package org.softmed.rest.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.softmed.rest.config.Parameter;

public class Handler {
	Long id;

	boolean active = true;

	String path;

	List<Parameter> parameters = new ArrayList<Parameter>();

	public Handler() {

	}

	public Handler(String path, boolean active) {
		this.path = path;
		this.active = active;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public List<Parameter> getParameters() {
		return parameters;
	}

	public Map<String, String> getParametersAsMap() {

		Map<String, String> values = new HashMap<String, String>();
		for (Parameter parameter : parameters) {
			values.put(parameter.getName(), parameter.getValue());
		}
		return values;

	}

	public void setParameters(List<Parameter> parameters) {
		this.parameters = parameters;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	private Object readResolve() {
		parameters = new ArrayList<Parameter>();
		return this;
	}

}
